﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NENAData.Factory;
using NENAData.LINQ;
using NENAData.NENAProvinces;
using NENAData.Transactions;

namespace NENAData.NENAProvinces
{
    public class AffiliateMembers
    {
        private static MembershipDataContext GetSQLTransaction()
        {
            var x = new SQLMembership();
            return x.GetMembershipDB();
        }

        public List<Member> PaidAffiliateMembers(ProvinceList pProvinces, TransactionList.Transactions pTransactionType)
        {

            MembershipDataContext db = GetSQLTransaction();
            var listMembers = (from m in db.Members
                                join tp in db.TransactionPayments on m.Member_ID equals tp.Member_ID
                                where tp.TransactionID_NENA == Convert.ToInt32(pTransactionType)
                                      && tp.TransactionCompleted
                                select m).ToList();

            if (pProvinces != ProvinceList.AllActiveAffiliates)
            {
                listMembers = (from m in listMembers
                           where m.Affiliate_ID == Convert.ToInt32(pProvinces)
                           select m).ToList();
            }
            return listMembers;
        }
    }
}
